<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>使用random()来返回0到1之间的随机数</title>
</head>

<body>
    <p id="demo">点击按钮显示一个随机数</p>
    <button onclick="myFunction()">点我</button>
    <script>
        function myFunction() {
            document.getElementById("demo").innerHTML = Math.random();
        }
    </script>
</body>

</html>